package cn.me.alphamq.common.enumeration;

/**
 * 消费状态的枚举类
 *
 * @author f
 */
public enum ConsumeStatusEnum {
    CONSUME_SUCCESS(0, "消费成功"),
    // TODO 之后做重试消息时会再用到这个枚举
    CONSUME_LATER(1, "之后再次消费");

    // 根据枚举的 code 属性获取枚举
    public static ConsumeStatusEnum of(int code) {
        for (ConsumeStatusEnum status : ConsumeStatusEnum.values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new RuntimeException("invalid consume status code: " + code);
    }

    private final int code;
    private final String desc;

    ConsumeStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

}
